package com.ehsy.statement;

import com.ehsy.common.ResponseVo;
import com.ehsy.model.UserInfo;
import com.ehsy.service.UrlParamService;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import javax.annotation.Resource;
import java.util.*;

/**
 * @author YanZhen_Li
 * @version 1.0
 * @title Url参数
 * @description
 * @create 2024/6/17 15:22
 */
@SpringBootTest
public class A3Url参数 {
    @Resource
    UrlParamService service;

    /**
     * 普通请求参数传递
     */
    @Test
    public void testUrl1() {
        ResponseVo<Object> test1 = service.send1("a", "b");
        ResponseVo<Object> test2 = service.send2("a", "b");
        ResponseVo<Object> test3 = service.send3("a=a&b=b");
        ResponseVo<Object> test4 = service.send4("a", "b");
        Map<String, Object> params = new HashMap<String,Object>(){{
            put("a", "a");
            put("b", "b");
            put("id", 0);
            put("c", "c");
            put("d", "d");
        }};
        ResponseVo<Map<String, Object>> test5 = service.send5(params);
        UserInfo userInfo = new UserInfo("张三", "18", "男", "上海", "13812341234", "123@qq.com", "123456");
        ResponseVo<UserInfo> test6 = service.send6(userInfo);

        System.out.println(test1.getData());
        System.out.println(test2.getData());
        System.out.println(test3.getData());
        System.out.println(test4.getData());
        System.out.println(test5.getData());
        System.out.println(test6.getData());
    }
    /**
     * 数组请求参数传递
     */
    @Test
    public void testUrl2() {
        Integer[] idArray = new Integer[]{10,20,30,40,50,60,70,80,90};
        List<Integer> idList = Arrays.asList(idArray);
        ResponseVo<List<Integer>> test7 = service.send7(idList);
        ResponseVo<List<Integer>> test8 = service.send8(idArray);

        System.out.println(test7.getData());
        System.out.println(test8.getData());
    }

    /**
     * 延迟quary参数
     */
    @Test
    public void testUrl3() {
        ResponseVo<Map<String, Object>> test9 = service.send9("aaa", "bbb", req -> {
            System.out.println(req);
            return "张三丰";
        });
        System.out.println(test9);
    }
}
